﻿Param(
$Path = $env:ProgramFiles +'\BGInfo'
)

Begin {}

Process {

    # Install BGInfo
    if (!(Test-Path $Path))
    {
    New-Item -ItemType Directory -Path $Path  
    Copy-Item -Path ($TSEnv:DeployRoot +"\Tools\x64\BGInfo64.exe") -Destination $Path
    Copy-Item -Path ($TSEnv:DeployRoot +"\Scripts\Desktop.BGI") -Destination $Path

    }

    # Create Scheduled Task

    Write-Host "Creating Scheduled task"

    CMD /C 'schtasks /create /tn "\"Desktop Background"\" /tr "\"C:\Program Files\BGinfo\Bginfo64.exe\" \"C:\Program Files\BGinfo\Desktop.bgi\" /nolicprompt /timer:0" /sc onlogon'

    # Run BGInfo
    schtasks /run /tn $TaskName

}

End{}










